package com.gs.SynAntiWandering.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.gs.SynAntiWandering.R;
import com.gs.SynAntiWandering.adapter.base.BasePagerAdapter;
import com.gs.SynAntiWandering.db.dto.WorkOrderPhotosDto;
import com.gs.SynAntiWandering.util.ImageUtil;

import java.util.List;

public class ImgBannerAdapter extends BasePagerAdapter<WorkOrderPhotosDto> {

    public ImgBannerAdapter(Activity activity, Context context, List<WorkOrderPhotosDto> mData, int layoutId) {
        super(activity, context, mData, layoutId);
    }

    @Override
    public Object convert(ViewGroup container, WorkOrderPhotosDto bean, int position) {
        ImageView iv = fd(R.id.iv_banner);
        ImageUtil.getInstance().loadImg(activity, bean.getPhoto(), iv);
        iv.setOnLongClickListener(v -> {
            if (onItemLongClickListener != null) {
                onItemLongClickListener.onLongClickListener(v, position);
            }
            return true;
        });
        iv.setOnClickListener(v -> {
            if (onItemClickListener != null) {
                onItemClickListener.onClickListener(v, position);
            }
        });
        container.addView(iv);
        return iv;
    }
}
